namespace cnVery.bbs.UI.Forum
{
    using cnVery.bbs.Kernel;
    using cnVery.Controls;
    using System;
    using System.Data;
    using System.Text;

    public class bbstree : Main
    {
        protected Span itemarray;

        private void GetArrayData()
        {
            StringBuilder builder = new StringBuilder();
            int num = 0;
            string sql = "select categoryname as name, (id + 10000) as id, '0' as pid from bbs_category order by sortid asc";
            IDataReader reader = base.conn.GetReader(sql);
            while (reader.Read())
            {
                builder.Append(string.Concat(new object[] { "arr[", num++, "]\t\t= {level:0, id:", reader["id"], ", pid:", reader["pid"], ", name:'", reader["name"], "'\t};\r\n" }));
            }
            reader.Close();
            sql = "select boardname as name, id, parentid, (categoryid + 10000) as pid from bbs_board where categoryid>0 order by sortid asc";
            reader = base.conn.GetReader(sql);
            while (reader.Read())
            {
                int num2 = (int) reader["parentid"];
                int num3 = 2;
                if (num2 < 1)
                {
                    num2 = (int) reader["pid"];
                    num3 = 1;
                }
                builder.Append(string.Concat(new object[] { "arr[", num++, "]\t\t= {level:", num3, ", id:", reader["id"], ", pid:", num2, ", name:'", reader["name"], "'\t};\r\n" }));
            }
            reader.Close();
            this.itemarray.Text = builder.ToString().Trim();
        }

        private void InitializeComponent()
        {
            base.Load += new EventHandler(this.Page_Load);
        }

        protected override void OnInit(EventArgs e)
        {
            this.InitializeComponent();
            base.OnInit(e);
        }

        private void Page_Load(object sender, EventArgs e)
        {
            this.GetArrayData();
            this.Finish();
        }
    }
}

